<template>
  <div>
    <h2>News</h2>
    <button @click="toNewsItem('二十大召开', '001')">二十大召开....</button>
    <button @click="toNewsItem('今天没有晚自习', '002')">今天没有晚自习</button>
    <button @click="toNewsItem('今年过年30天假期', '003')">
      今年过年30天假期
    </button>
    <router-view></router-view>
  </div>
</template>

<script lang="ts">
import { defineComponent } from "vue";

export default defineComponent({
  name: "News",
});
</script>

<script setup lang="ts">
import { useRouter } from "vue-router";
const router = useRouter();
//路由导航
const toNewsItem = (title: string, id: string) => {
  router.push({
    name: "newsItem",
    query: {
      title,
      id,
    },
  });
};
</script>

<style scoped></style>
